+2007-01-06 Michael Schumacher <schumaml@cvs.gnome.org>
+
+ This change makes babl buildable on Windows.
+
+ * configure.ac: Add a check for function dlopen and disabled
+ static libs by default. Check for gettimeofday by using
+ AC_REPLACE_FUNCS.
+
+ * babl/babl-internal.h: Add definitions for srandom and radnom to
+ srand and rand for the windows platform.
+ * babl/babl-conversion.c
+ * babl-model.c: Include babl-internal.h after math.h
+
+ * babl/babl-extension.c: Use #ifdef HAVE_DLOPEN to hide dl* if it
+ is not available.
+
+ * babl/Makefile.am: Removed win32_libs and added @LTLIBOBJS@ to
+ LIBADD to get the replacement for gettimeofday linked in if
+ needed.
+
+ * babl/gettimeofday.c: New file to provide a replacement for
+ gettimeofday, only used on Windows yet.
+
2007-01-06 Michael Schumacher <schumaml@cvs.gnome.org>
* Makefile.am: don't go into the extensions subdirectory on
## Source directory
if OS_WIN32
-win32_libs = -lgw32c -lole32 -luuid -lwsock32
no_undefined = -no-undefined
endif
libbabl_la_SOURCES= $(h_sources) $(c_sources)
libbabl_la_LIBADD=\
base/libbase.la \
- ${win32_libs}
+ @LTLIBOBJS@
libbabl_la_LDFLAGS= \
-version-info $(BABL_LIBRARY_VERSION) \
* Boston, MA 02111-1307, USA.
*/
-#include "babl-internal.h"
-#include "babl-db.h"
+
#include <string.h>
#include <stdarg.h>
#include <math.h>
+#include "babl-internal.h"
+#include "babl-db.h"
static int
each_babl_conversion_destroy (Babl *babl,
#ifdef HAVE_DLFCN_H
#include <dlfcn.h>
-#else
-void *dlopen(const char *, int);
-void *dlsym(void *, const char *);
-int dlclose(void *);
-char *dlerror(void);
#endif
#ifndef RTLD_NOW
{
Babl *babl = NULL;
+#ifdef HAVE_DLOPEN
/* do the actual loading thing */
void *dl_handle = NULL;
int (*init) (void) = NULL;
babl_log ("babl_extension_init() in extension '%s' failed (return!=0)", path);
return load_failed (babl);
}
+#endif
if (babl_db_insert (db, babl) == babl)
{
{
if (babl->extension.destroy)
babl->extension.destroy();
-#ifdef BABL_DYNAMIC_EXTENSIONS
+#ifdef HAVE_DLOPEN
if (babl->extension.dl_handle)
dlclose (babl->extension.dl_handle);
#endif
#include "babl-util.h"
#include "babl-memory.h"
+/* redefining some functions for the win32 platform */
+#ifdef _WIN32
+#define srandom srand
+#define random rand
+#endif
Babl * babl_conversion_find (void *source,
void *destination);
* Boston, MA 02111-1307, USA.
*/
-#include "babl-internal.h"
#include <string.h>
#include <stdarg.h>
#include <math.h>
+#include "babl-internal.h"
#include "babl-db.h"
--- /dev/null
+/*\r
+ * timeval.h 1.0 01/12/19\r
+ *\r
+ * Defines gettimeofday, timeval, etc. for Win32\r
+ *\r
+ * By Wu Yongwei\r
+ *\r
+ */\r
+\r
+#ifdef _WIN32\r
+\r
+#define WIN32_LEAN_AND_MEAN\r
+#include <windows.h>\r
+#include <time.h>\r
+\r
+#ifndef __GNUC__\r
+#define EPOCHFILETIME (116444736000000000i64)\r
+#else\r
+#define EPOCHFILETIME (116444736000000000LL)\r
+#endif\r
+\r
+struct timeval {\r
+ long tv_sec; /* seconds */\r
+ long tv_usec; /* microseconds */\r
+};\r
+\r
+struct timezone {\r
+ int tz_minuteswest; /* minutes W of Greenwich */\r
+ int tz_dsttime; /* type of dst correction */\r
+};\r
+\r
+\r
+int gettimeofday(struct timeval *tv, struct timezone *tz)\r
+{\r
+ FILETIME ft;\r
+ LARGE_INTEGER li;\r
+ __int64 t;\r
+ static int tzflag;\r
+\r
+ if (tv)\r
+ {\r
+ GetSystemTimeAsFileTime(&ft);\r
+ li.LowPart = ft.dwLowDateTime;\r
+ li.HighPart = ft.dwHighDateTime;\r
+ t = li.QuadPart; /* In 100-nanosecond intervals */\r
+ t -= EPOCHFILETIME; /* Offset to the Epoch time */\r
+ t /= 10; /* In microseconds */\r
+ tv->tv_sec = (long)(t / 1000000);\r
+ tv->tv_usec = (long)(t % 1000000);\r
+ }\r
+\r
+ if (tz)\r
+ {\r
+ if (!tzflag)\r
+ {\r
+ _tzset();\r
+ tzflag++;\r
+ }\r
+ tz->tz_minuteswest = _timezone / 60;\r
+ tz->tz_dsttime = _daylight;\r
+ }\r
+\r
+ return 0;\r
+}\r
+\r
+#endif /* _WIN32 */\r
AM_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE(no-define)
+AC_DISABLE_STATIC
AC_PROG_CC
AC_LIBTOOL_WIN32_DLL
AM_PROG_LIBTOOL
AC_CHECK_LIB([dl], [dlopen], [DL_LIB="-ldl"])
AC_SUBST(DL_LIB)
+AC_CHECK_FUNCS(dlopen)
+AC_REPLACE_FUNCS(gettimeofday)
+
AC_DEFINE_UNQUOTED(BABL_PATH, "~/.babl-$BABL_API_VERSION:/usr/local/lib/babl-$BABL_API_VERSION:/usr/lib/babl-$BABL_API_VERSION", [search path for babl extensions (default value of enviroment variable)])
AC_DEFINE(BABL_PATH_SEPERATOR, "/", [string used to seperate directories in a path string])
AC_DEFINE(BABL_LIST_SEPERATOR, ':', [seperator between paths in BABL_PATH])